package bm.com.project.server.organization.service.impl;

import bm.com.project.server.common.dto.BmSysChangeOrgListDTO;
import bm.com.project.server.organization.entity.BmOrgEntity;
import bm.com.project.server.organization.mapper.BmOrgMapper;
import bm.com.project.server.organization.mapper.BmOrgMemberMapper;
import bm.com.project.server.organization.service.OrgService;
import bm.com.framework.common.resp.PageVO;
import bm.com.framework.common.resp.Result;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrgServiceImpl extends ServiceImpl<BmOrgMapper, BmOrgEntity> implements OrgService {

    @Autowired
    BmOrgMemberMapper bmOrgMemberDao;

    @Autowired
    BmOrgMapper bmOrgDao;

    /**
     * 获取组织列表
     * @param userId
     * @return
     */
    @Override
    public PageVO<List> getOrgList(String userId) {
        List orgList = bmOrgMemberDao.getOrgListByUserId(userId);
        return new PageVO<>(orgList.size(),orgList);
    }


    /**
     * 获取组织列表
     *
     * @param userId
     * @return
     */
    @Override
    public List<BmSysChangeOrgListDTO> getOrgListCommon(String userId) {
        return bmOrgMemberDao.getOrgListByUserIdCommon(userId);
    }

    /**
     * 获取组织详情
     * @param orgId
     * @return
     */
    @Override
    public Result<BmOrgEntity> getOrgDetail(String orgId) {
        BmOrgEntity bmOrgEntity = bmOrgDao.selectById(orgId);
        return new Result<BmOrgEntity>().ok(bmOrgEntity);
    }

}
